/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * NuGat-API named Chameleon developed by Simon De Baets to Verimag.
 *
 */
package chameleon.view.command;

import chameleon.model.AbstractManager;
import chameleon.view.input.Input;

/**
 *
 * @author simon
 */
public class PrintStrategyCommand extends Command {
    
    private String file_;
    
    public PrintStrategyCommand(Input input, String file, boolean help){
        super (input, false, help);
        file_= file;
    }

    @Override
    public Input execute() {
        
        if(help_){
            outputManager_.displayString(""
                    + "print_strategy [-filename | -h ]\n"
                    + "print the last strategy computes with compute_strategy"
                    + "in the given file\n");
        }
        else{
            
            InternalCheckCommand check = new InternalCheckCommand(input_, 3);
            if (check.isOk()){
                AbstractManager manager = input_.getManager();
                if(manager.strategyExists())
                    manager.printStrategy(file_);
                else
                    outputManager_.displayString("No strategy present in structure!\n"
                            + "Please use compute_strategy.\n");
            }
        }
        
        return input_;
    }
    
}
